package com.sambo.inspection.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.sambo.inspection.R;
import com.sambo.inspection.activity.support.BaseActivity;

/**
 * Created by RY001 on 2019/2/27.
 */

public class ChangeInfoActivity extends BaseActivity implements View.OnClickListener {
    ImageView ivBack;
    TextView tvInfo;
    EditText etInfo;
    TextView tvFinish;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_changeinfo);
        ivBack = findViewById(R.id.iv_back);
        tvInfo = findViewById(R.id.tv_info);
        etInfo = findViewById(R.id.et_old_info);
        tvFinish = findViewById(R.id.tv_finish);

        String title = getIntent().getStringExtra("title");
        String content = getIntent().getStringExtra("content");

        tvInfo.setText(title);
        etInfo.setText(content);

        ivBack.setOnClickListener(this);
        tvFinish.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_finish:
                setResult(RESULT_OK, new Intent().putExtra("content", etInfo.getText().toString()));
                finish();
                break;
        }
    }
}
